package com.yanqu.road.server.cmd.activity.tongbing;

import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.TongBingProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.cmd.CrossUnionCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.manager.activity.tongbing.CrossTongBingMgr;
import com.yanqu.road.server.manager.activity.tongbing.activity.CrossTongBingActivity;
import com.yanqu.road.server.protocol.CrossProtocol;

@Cmd(code = CrossProtocol.C2_TONG_BING_UPDATE_HORSE, desc = "")
public class CrossTongBingChangeHorseCmd extends CrossUnionCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        TongBingProto.CrossTongBingChangeHorseReqMsg reqMsg = TongBingProto.CrossTongBingChangeHorseReqMsg.parseFrom(packet.getBytes());
        CrossTongBingActivity activity = CrossTongBingMgr.getActivity(reqMsg.getActivityId(), groupId);
        try {
            activity.changeHorse(packet.getPlayerId(), reqMsg.getHorse());
        } catch (Exception e) {
            e.printStackTrace();
            log.error("tong bing add horse fail! activityId {} userId {} horseId {}.", reqMsg.getActivityId(), packet.getPlayerId(), reqMsg.getHorse());
        }
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {

    }

    @Override
    public void sendData() {

    }
}
